#ifndef HPCDATABASE_H
#define HPCDATABASE_H

#include <QObject>
#include <QString>
#include <QtXml/QDomDocument>
#include <QtSql/QSqlDatabase>
#include <QMap>
#include "HPCSensor.h"
#include "HPCClientInfo.h"

class HPCDatabase : public QObject
{
    Q_OBJECT
public:
//    explicit HPCDatabase(QObject *parent = 0);
    explicit HPCDatabase(QString& host, QString& usr, QString& pwd, QString& dbname, QString& appPath);
    virtual ~HPCDatabase();

    void checkStation();
    virtual inline int DBState() const
        { return this-> m_State; }
    bool getConfig(QDomDocument* docCfg);
    void writeMeasureValues(QString values);
    void writeActValue (uint id, const HPCValue& val);

protected:

private:
    QString m_Host;
    QString m_User;
    QString m_Pwd;
    QString m_DbName;
    int   m_State;
    QSqlDatabase m_db;
    long  m_ServerId;
    QString m_ServerTitle;
    QString m_MacAdress;
    QString m_CacheFile;
    QString m_XMLConfigFile;

    QString getMacAddres();
    void writeMeasureValuesToDB(QString values);
    void writeMeasureValuesToFile(QString values);
    bool connectAndRegister(bool first);
    void checkAndWriteLocalMeasureValues();
    bool getConfigFromDB(QDomDocument* docCfg);
    bool getConfigFromXML(QDomDocument* docCfg);
    void checkServer();

signals:

public slots:
};


#endif // HPCDATABASE_H
